package aures.ui;

import aures.Exceptions.EGuiBuildError;
import org.gnome.gtk.*;

public class AuresLogin extends AuresWin{
	final ComboBox cmbServer;
	final Entry entryPort;
	final Entry entryNick;
	final Entry entryUser;
	final Entry entryPass;
	final Label lblLogin;
	final Button btnLoginGo;
	final Button btnLoginExit;

	public AuresLogin (String src, String root) throws Exception{
		super (src, root);
		
		/* Bring widgets instances */
		cmbServer =    (ComboBox)	getWidget("cmbServer");
		entryPort =    (Entry)		getWidget("entryPort");
		entryNick =    (Entry)		getWidget("entryNick");
		entryUser =    (Entry)		getWidget("entryUser");
		entryPass =    (Entry)		getWidget("entryPass");
		lblLogin =     (Label)		getWidget("lblLogin");
		btnLoginGo =   (Button)		getWidget("btnLoginGo");
		btnLoginExit = (Button)		getWidget("btnLoginExit");
		
		if ((cmbServer == null)||(entryPort == null)||(entryNick == null)||(entryUser == null)||
			(entryPass == null)||(lblLogin == null)||(btnLoginGo == null)||(btnLoginExit == null)){
			
			throw new EGuiBuildError("the glade file may be corrupted");
		}
		
	}
	
	public void build (){
		
		win.setTitle("Aures");
		((Entry)(cmbServer.getChild())).setText("127.0.0.1");


		btnLoginGo.connect(new Button.Clicked() {
            public void onClicked(Button source) {
                System.out.println("Here connection should be established");
            }
        });
	
		btnLoginExit.connect(new Button.Clicked(){
			public void onClicked (Button src){
				AuresLogin.this.Destroy();
			}
		});
		
	}
	
	public boolean checkFields (){
		return true;
	}
	
	public void Go(){
		
	}
	
}
